import request from '@/axios'
import type { TenaneQueryCriteria, TenantTableView, TenantForm } from './types'

const pathPrefix = '/api/tenant'

export const query = (data: PaginationRequest<TenaneQueryCriteria>): Promise<PaginationResponse<TenantTableView>> => {
  return request.post({
    url: `${pathPrefix}/query`,
    data
  })
}

export const form = (id: string): Promise<TenantForm> => {
  return request.get({
    url: `${pathPrefix}/${id}`
  })
}

export const add = (data: TenantForm): Promise<ApiResult> => {
    return request.post({
        url: `${pathPrefix}`,
        data
    })
}

export const edit = (id: string, data: TenantForm): Promise<ApiResult> => {
    return request.put({  
        url: `${pathPrefix}/${id}`,
        data
  })
}